package com.xykj.enterprise.wechat.wap.config;

import com.ydn.appserver.ClientConfiguration;
import com.ydn.appserver.MinaAppClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author YangYiQun
 */
@Configuration
public class BusiConfig {

    @Value("${busi.addrs}")
    private String addrs;

    @Value("${busi.coTimeout}")
    private Integer coTimeout;

    @Value("${busi.soTimeout}")
    private Integer soTimeout;

    @Value("${busi.maxConn}")
    private Integer maxConn;

    @Bean(value = "busiClient")
    public MinaAppClient createBusi() {
        ClientConfiguration configuration = new ClientConfiguration();
        configuration.setServerAddressesString(addrs);
        configuration.setMaxConnectionsPerServer(maxConn);
        configuration.setSocketConnTimeoutSec(coTimeout);
        configuration.setSocketDataTimeoutSec(soTimeout);
        return new MinaAppClient(configuration);
    }

}
